package com.lei.mydb.backend.vm;


import com.lei.mydb.backend.dm.DataManager;
import com.lei.mydb.backend.tm.TransactionManager;

/**
 * @author 1192299468@qq.com
 * @version 1.0
 * @date 2025/5/3 10:08
 * @description: 事务和数据版本
 */
public interface VersionManager {
    byte[] read(long xid, long uid) throws Exception;
    long insert(long xid, byte[] data) throws Exception;
    boolean delete(long xid, long uid) throws Exception;

    long begin(int level);
    void commit(long xid) throws Exception;
    void abort(long xid);

    public static VersionManager newVersionManager(TransactionManager tm, DataManager dm) {
        return new VersionManagerImpl(tm, dm);
    }
}
